package com.pheruagor.handmanager.controller {
    import com.pheruagor.handmanager.model.MemberEditionPopUpProxy;
    import com.pheruagor.handmanager.view.MemberEditionPopUpMediator;
    import com.pheruagor.handmanager.view.component.MemberEditionPopUp;

    import flash.display.DisplayObject;

    import mx.managers.PopUpManager;

    import org.puremvc.as3.interfaces.INotification;
    import org.puremvc.as3.patterns.command.SimpleCommand;

    public class OpenMemberEditionPopUpCommand extends SimpleCommand {
        public static const NAME:String = "openMemberEditionPopUpCommand";
        public static const EXECUTED:String = NAME + "Executed";

        override public function execute(notification:INotification):void {
            if (notification.getBody() == null) {
                throw new ArgumentError("Notification must contain dispay object");
            }
            facade.registerProxy(new MemberEditionPopUpProxy(notification.getBody().member));
            var popupContainer:DisplayObject = DisplayObject(notification.getBody().container);
            var popup:MemberEditionPopUp = new MemberEditionPopUp();
            facade.registerMediator(new MemberEditionPopUpMediator(popup));
            PopUpManager.addPopUp(popup, popupContainer, true);
            PopUpManager.centerPopUp(popup);
        }
    }
}